function request(ops) {
  let {
    url,
    success,
    type = "get",
    data = {},
    error,
    timeout = 1000,
    dataType = "text",
    myFiled = "",
  } = ops;
  let str = "";
  for (let i in data) {
    str += `${i}=${data[i]}&`;
  }

  if (type !== "post") {
    url = url + "?" + str + "_smkt=" + Date.now();
  }

  let xhr;
  if (type !== "jsonp") {
    xhr = new XMLHttpRequest();
    xhr.open(type, url);
    xhr.onload = function () {
      if (xhr.status === 200) {
        const res = dataType === "json" ? JSON.parse(xhr.responseText) : xhr.responseText;
        success && success(res);
        error = null;
        success = null;
      } else {
        error && error();
        error = null;
        success = null;
      }
    };
    if (type === "get") {
      xhr.send();
    } else {
      xhr.setRequestHeader("content-Type", "application/x-www-form-urlencoded");
      xhr.send(str.slice(0, str.length - 1));
    }
  } else {
    const s = document.createElement("script");
    s.src = url;
    s.id = "aa";
    document.body.appendChild(s);
    window[data[myFiled]] = function (res) {
      res = dataType === "json" ? JSON_parse(res) : res;
      success && success(res);
      s && s.remove();
      error = null;
      success = null;
    };
  }
  setTimeout(() => {
    error && error("timeout");
    const sc = document.getElementById("aa");
    sc && sc.remove();
    error = null;
    success = null;
  }, timeout);
}
